﻿using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Web;

namespace QAS.NekoramaZ.DAOs
{
    public class NewQuestionDAO
    {

        String conStr = ConfigurationManager.ConnectionStrings[2].ConnectionString;//"Server=localhost; Database=QAS.Nekorama; Integrated Security=true";
        SqlConnection con;
        public void connectDb()
        {
            try
            {
                SqlConnection con = new SqlConnection(conStr);
            }
            catch (Exception e)
            {
            }
        }

        public void InsertNewQuestion(int BountyID, int TagID1, int TagID2, int TagID3, int TagID4, int TagID5, String Title, String Content, DateTime Createddate, int CreatedUser)
        {

            //create data adapter
            string sql = " INSERT INTO Questions " +
                                      " ( BountyID, TagID1, TagID2, TagID3, TagID4, TagID5, Title, Content, CreatedDate, CreatedUser)" +
                         " VALUES " +
                                     " ( @BountyID  , @TagID1, @TagID2, @TagID3, @TagID4, @TagID5, @Title, @Content, @CreatedDate, @CreatedUser)";
            SqlCommand cmd = new SqlCommand(sql, con);
            con.Open();


            cmd.Parameters.Add("BountyID", SqlDbType.Int);
            cmd.Parameters["BountiID"].Value = BountyID;

            cmd.Parameters.Add("TagID1", SqlDbType.Int);
            cmd.Parameters["TagID1"].Value = TagID1;

            cmd.Parameters.Add("TagID1", SqlDbType.Int);
            cmd.Parameters["TagID1"].Value = TagID2;

            cmd.Parameters.Add("TagID1", SqlDbType.Int);
            cmd.Parameters["TagID1"].Value = TagID3;

            cmd.Parameters.Add("TagID1", SqlDbType.Int);
            cmd.Parameters["TagID1"].Value = TagID4;

            cmd.Parameters.Add("TagID1", SqlDbType.Int);
            cmd.Parameters["TagID1"].Value = TagID5;

            cmd.Parameters.Add("Title", SqlDbType.NVarChar);
            cmd.Parameters["Title"].Value = Title;

            cmd.Parameters.Add("Content", SqlDbType.NVarChar);
            cmd.Parameters["Content"].Value = Content;

            cmd.Parameters.Add("Createddate", SqlDbType.DateTime);
            cmd.Parameters["Createddate"].Value = Createddate;

            cmd.Parameters.Add("Createduser", SqlDbType.Int);
            cmd.Parameters["Createduser"].Value = CreatedUser;

            cmd.ExecuteNonQuery();
            con.Close();
        }
    }
}